<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持</title>
    <meta name="description" content="xmake 是一个基于 Lua 的轻量级跨平台构建工具，使用 xmake.lua 维护项目构建，相比 makefile/CMakeLists.txt，配置语法更加简洁直观，对新手非常友好，短时间内就能快速入门，能够让用户把更多的精力集中在实际的项目开发上。这个版本，我们新增了很多新特性，不仅增加了对 Vala 和...">

    
    <meta name="keywords" content="xmake,lua,C/C++,lock,package,vala,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/2021/08/29/xmake-update-v2.5.7/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2021-08-29
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a-->
        <a href="/cn/tag/#lua" title="Tag: lua" rel="tag">lua</a>&nbsp;
    
        <!--a href="/tag/#C%2FC%2B%2B" title="Tag: C/C++" rel="tag">C/C++</a-->
        <a href="/cn/tag/#C/C++" title="Tag: C/C++" rel="tag">C/C++</a>&nbsp;
    
        <!--a href="/tag/#lock" title="Tag: lock" rel="tag">lock</a-->
        <a href="/cn/tag/#lock" title="Tag: lock" rel="tag">lock</a>&nbsp;
    
        <!--a href="/tag/#package" title="Tag: package" rel="tag">package</a-->
        <a href="/cn/tag/#package" title="Tag: package" rel="tag">package</a>&nbsp;
    
        <!--a href="/tag/#vala" title="Tag: vala" rel="tag">vala</a-->
        <a href="/cn/tag/#vala" title="Tag: vala" rel="tag">vala</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p><a href="https://github.com/xmake-io/xmake">xmake</a> 是一个基于 Lua 的轻量级跨平台构建工具，使用 xmake.lua 维护项目构建，相比 makefile/CMakeLists.txt，配置语法更加简洁直观，对新手非常友好，短时间内就能快速入门，能够让用户把更多的精力集中在实际的项目开发上。</p>

<p>这个版本，我们新增了很多新特性，不仅增加了对 Vala 和 Metal 语言的编译支持，另外我们还改进了包依赖管理，能够像 npm/package.lock 那样支持对依赖包的锁定和更新，使得用户的项目不会受到上游包仓库的更新变动影响。</p>

<p>此外，我们还提供了一些比较实用的规则， 比如 <code class="highlighter-rouge">utils.bin2c</code> 可以让用户方便快速的内嵌一些二进制资源文件到代码中去，以头文件的方式获取相关数据。</p>

<ul>
  <li><a href="https://github.com/xmake-io/xmake">项目源码</a></li>
  <li><a href="https://xmake.io/#/zh-cn/">官方文档</a></li>
  <li><a href="https://xmake.io/#/zh-cn/about/course">入门课程</a></li>
</ul>

<h2 id="新特性介绍">新特性介绍</h2>

<h3 id="新增-vala-语言支持">新增 Vala 语言支持</h3>

<p>这个版本，我们已经可以初步支持构建 Vala 程序，只需要应用 <code class="highlighter-rouge">add_rules("vala")</code> 规则。</p>

<p>同时，我们需要添加一些依赖包，其中 glib 包是必须的，因为 vala 自身也会用到它。</p>

<p><code class="highlighter-rouge">add_values("vala.packages")</code> 用于告诉 valac，项目需要哪些包，它会引入相关包的 vala api，但是包的依赖集成，还是需要通过 <code class="highlighter-rouge">add_requires("lua")</code> 下载集成。</p>

<p>例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.release"</span><span class="p">,</span> <span class="s2">"mode.debug"</span><span class="p">)</span>

<span class="n">add_requires</span><span class="p">(</span><span class="s2">"lua"</span><span class="p">,</span> <span class="s2">"glib"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"vala"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.vala"</span><span class="p">)</span>
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"lua"</span><span class="p">,</span> <span class="s2">"glib"</span><span class="p">)</span>
    <span class="n">add_values</span><span class="p">(</span><span class="s2">"vala.packages"</span><span class="p">,</span> <span class="s2">"lua"</span><span class="p">)</span>
</code></pre>
</div>

<p>更多例子：<a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/vala">Vala examples</a></p>

<h3 id="新增包依赖锁定支持">新增包依赖锁定支持</h3>

<p>这个特性类似 npm 的 package.lock, cargo 的 cargo.lock。</p>

<p>比如，我们引用一些包，默认情况下，如果不指定版本，那么 xmake 每次都会自动拉取最新版本的包来集成使用，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">)</span>
</code></pre>
</div>

<p>但如果上游的包仓库更新改动，比如 zlib 新增了一个 1.2.11 版本，或者安装脚本有了变动，都会导致用户的依赖包发生改变。</p>

<p>这容易导致原本编译通过的一些项目，由于依赖包的变动出现一些不稳定因素，有可能编译失败等等。</p>

<p>为了确保用户的项目每次使用的包都是固定的，我们可以通过下面的配置去启用包依赖锁定。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">set_policy</span><span class="p">(</span><span class="s2">"package.requires_lock"</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span>
</code></pre>
</div>

<p>这是一个全局设置，必须设置到全局根作用域，如果启用后，xmake 执行完包拉取，就会自动生成一个 <code class="highlighter-rouge">xmake-requires.lock</code> 的配置文件。</p>

<p>它包含了项目依赖的所有包，以及当前包的版本等信息。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="p">{</span>
    <span class="n">__meta__</span> <span class="o">=</span> <span class="p">{</span>
        <span class="n">version</span> <span class="o">=</span> <span class="s2">"1.0"</span>
    <span class="p">},</span>
    <span class="p">[</span><span class="s2">"macosx|x86_64"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">[</span><span class="s2">"cmake#31fecfc4"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">repo</span> <span class="o">=</span> <span class="p">{</span>
                <span class="n">branch</span> <span class="o">=</span> <span class="s2">"master"</span><span class="p">,</span>
                <span class="n">commit</span> <span class="o">=</span> <span class="s2">"4498f11267de5112199152ab030ed139c985ad5a"</span><span class="p">,</span>
                <span class="n">url</span> <span class="o">=</span> <span class="s2">"https://github.com/xmake-io/xmake-repo.git"</span>
            <span class="p">},</span>
            <span class="n">version</span> <span class="o">=</span> <span class="s2">"3.21.0"</span>
        <span class="p">},</span>
        <span class="p">[</span><span class="s2">"glfw#31fecfc4"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">repo</span> <span class="o">=</span> <span class="p">{</span>
                <span class="n">branch</span> <span class="o">=</span> <span class="s2">"master"</span><span class="p">,</span>
                <span class="n">commit</span> <span class="o">=</span> <span class="s2">"eda7adee81bac151f87c507030cc0dd8ab299462"</span><span class="p">,</span>
                <span class="n">url</span> <span class="o">=</span> <span class="s2">"https://github.com/xmake-io/xmake-repo.git"</span>
            <span class="p">},</span>
            <span class="n">version</span> <span class="o">=</span> <span class="s2">"3.3.4"</span>
        <span class="p">},</span>
        <span class="p">[</span><span class="s2">"opengl#31fecfc4"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">repo</span> <span class="o">=</span> <span class="p">{</span>
                <span class="n">branch</span> <span class="o">=</span> <span class="s2">"master"</span><span class="p">,</span>
                <span class="n">commit</span> <span class="o">=</span> <span class="s2">"94d2eee1f466092e04c5cf1e4ecc8c8883c1d0eb"</span><span class="p">,</span>
                <span class="n">url</span> <span class="o">=</span> <span class="s2">"https://github.com/xmake-io/xmake-repo.git"</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre>
</div>

<p>当然，我们也可以执行下面的命令，强制升级包到最新版本。</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> require --upgrade
</span>upgrading packages ..
  zlib: 1.2.10 -&gt; 1.2.11
1 package is upgraded!
</code></pre>
</div>

<h3 id="option-支持代码片段的运行时检测">option 支持代码片段的运行时检测</h3>

<p>option 本身有提供 <code class="highlighter-rouge">add_csnippets/add_cxxsnippets</code> 两个接口，用于快速检测特定一段 c/c++ 代码是否通过编译，如果编译通过就会启用对应 option 选项。</p>

<p>但之前的版本仅仅只能提供编译期检测，而新版本中，我们还新增了运行时检测支持。</p>

<p>我们可以通过设置 <code class="highlighter-rouge"><span class="p">{</span><span class="err">tryrun</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">true</span><span class="p">}</span></code> 和 <code class="highlighter-rouge"><span class="p">{</span><span class="err">output</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">true</span><span class="p">}</span></code> 两个参数，用于尝试运行检测和捕获输出。</p>

<h4 id="尝试运行检测">尝试运行检测</h4>

<p>设置 tryrun 可以尝试运行来检测</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">option</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_cxxsnippets</span><span class="p">(</span><span class="s2">"HAS_INT_4"</span><span class="p">,</span> <span class="s2">"return (sizeof(int) == 4)? 0 : -1;"</span><span class="p">,</span> <span class="p">{</span><span class="n">tryrun</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<p>如果编译运行通过，test 选项就会被启用。</p>

<h4 id="运行时检测并捕获输出">运行时检测并捕获输出</h4>

<p>设置 output 也会尝试去检测，并且额外捕获运行的输出内容。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">option</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_cxxsnippets</span><span class="p">(</span><span class="s2">"INT_SIZE"</span><span class="p">,</span> <span class="s1">'printf("%d", sizeof(int)); return 0;'</span><span class="p">,</span> <span class="p">{</span><span class="n">output</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="n">number</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<p>如果编译运行通过，test 选项就会被启用，同时能获取到对应的输出内容作为 option 的值。</p>

<p>注：设置为捕获输出，当前 option 不能再设置其他 snippets</p>

<p>我们也可以通过 <code class="highlighter-rouge">is_config</code> 获取绑定到option的输出。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="k">if</span> <span class="n">is_config</span><span class="p">(</span><span class="s2">"test"</span><span class="p">,</span> <span class="s2">"8"</span><span class="p">)</span> <span class="n">tben</span>
    <span class="c1">-- xxx</span>
<span class="k">end</span>
</code></pre>
</div>

<p>另外，我们也对 <code class="highlighter-rouge">includes("check_csnippets")</code> 的辅助检测接口，也做了改进来支持运行时检测。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">includes</span><span class="p">(</span><span class="s2">"check_csnippets.lua"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.c"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">)</span>

    <span class="n">check_csnippets</span><span class="p">(</span><span class="s2">"HAS_INT_4"</span><span class="p">,</span> <span class="s2">"return (sizeof(int) == 4)? 0 : -1;"</span><span class="p">,</span> <span class="p">{</span><span class="n">tryrun</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
    <span class="n">check_csnippets</span><span class="p">(</span><span class="s2">"INT_SIZE"</span><span class="p">,</span> <span class="s1">'printf("%d", sizeof(int)); return 0;'</span><span class="p">,</span> <span class="p">{</span><span class="n">output</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="n">number</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
    <span class="n">configvar_check_csnippets</span><span class="p">(</span><span class="s2">"HAS_LONG_8"</span><span class="p">,</span> <span class="s2">"return (sizeof(long) == 8)? 0 : -1;"</span><span class="p">,</span> <span class="p">{</span><span class="n">tryrun</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
    <span class="n">configvar_check_csnippets</span><span class="p">(</span><span class="s2">"PTR_SIZE"</span><span class="p">,</span> <span class="s1">'printf("%d", sizeof(void*)); return 0;'</span><span class="p">,</span> <span class="p">{</span><span class="n">output</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="n">number</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<p>如果启用捕获输出，<code class="highlighter-rouge">config.h.in</code> 的 <code class="highlighter-rouge">${define PTR_SIZE}</code> 会自动生成 <code class="highlighter-rouge">#define PTR_SIZE 4</code>。</p>

<p>其中，<code class="highlighter-rouge">number = true</code> 设置，可以强制作为 number 而不是字符串值，否则默认会定义为 <code class="highlighter-rouge">#define PTR_SIZE "4"</code></p>

<h3 id="快速内嵌二进制资源文件到代码">快速内嵌二进制资源文件到代码</h3>

<p>我们可以通过 <code class="highlighter-rouge">utils.bin2c</code> 规则，在项目中引入一些二进制文件，并见他们作为 c/c++ 头文件的方式提供开发者使用，获取这些文件的数据。</p>

<p>比如，我们可以在项目中，内嵌一些 png/jpg 资源文件到代码中。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"console"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binart"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"utils.bin2c"</span><span class="p">,</span> <span class="p">{</span><span class="n">extensions</span> <span class="o">=</span> <span class="p">{</span><span class="s2">".png"</span><span class="p">,</span> <span class="s2">".jpg"</span><span class="p">}})</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"res/*.png"</span><span class="p">,</span> <span class="s2">"res/*.jpg"</span><span class="p">)</span>
</code></pre>
</div>

<p>注：extensions 的设置是可选的，默认后缀名是 .bin</p>

<p>然后，我们就可以通过 <code class="highlighter-rouge">#include "filename.png.h"</code> 的方式引入进来使用，xmake 会自动帮你生成对应的头文件，并且添加对应的搜索目录。</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">static</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">g_png_data</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span>
    <span class="cp">#include "image.png.h"
</span><span class="p">};</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">**</span> <span class="n">argv</span><span class="p">)</span>
<span class="p">{</span>
    <span class="n">printf</span><span class="p">(</span><span class="s">"image.png: %s, size: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">g_png_data</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">g_png_data</span><span class="p">));</span>
    <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>

<p>生成头文件内容类似：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code>cat build/.gens/test/macosx/x86_64/release/rules/c++/bin2c/image.png.h
  0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x78, 0x6D, 0x61, 0x6B, 0x65, 0x21, 0x0A, 0x00
</code></pre>
</div>

<h3 id="新增-iosmacos-应用-metal-编译支持">新增 iOS/macOS 应用 Metal 编译支持</h3>

<p>我们知道 <code class="highlighter-rouge">xcode.application</code> 规则可以编译 iOS/macOS 应用程序，生成 .app/.ipa 程序包，并同时完成签名操作。</p>

<p>不过之前它不支持对带有 .metal 代码的编译，而新版本中，我们新增了 <code class="highlighter-rouge">xcode.metal</code> 规则，并默认关联到 <code class="highlighter-rouge">xcode.application</code> 规则中去来默认支持 metal 编译。</p>

<p>xmake 会自动编译 .metal 然后打包生成 default.metallib 文件，并且自动内置到 .app/.ipa 里面。</p>

<p>如果用户的 metal 是通过 <code class="highlighter-rouge">[_device newDefaultLibrary]</code> 来访问的，那么就能自动支持，就跟使用 xcode 编译一样。</p>

<p>这里是我们提供的一个完整的：<a href="https://github.com/xmake-io/xmake/blob/master/tests/projects/objc/metal_app/xmake.lua">项目例子</a>。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"HelloTriangle"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"xcode.application"</span><span class="p">)</span>
    <span class="n">add_includedirs</span><span class="p">(</span><span class="s2">"Renderer"</span><span class="p">)</span>
    <span class="n">add_frameworks</span><span class="p">(</span><span class="s2">"MetalKit"</span><span class="p">)</span>
    <span class="n">add_mflags</span><span class="p">(</span><span class="s2">"-fmodules"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"Renderer/*.m"</span><span class="p">,</span> <span class="s2">"Renderer/*.metal"</span><span class="p">)</span> <span class="c1">------- 添加 metal 文件</span>
    <span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"macosx"</span><span class="p">)</span> <span class="k">then</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"Application/main.m"</span><span class="p">)</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"Application/AAPLViewController.m"</span><span class="p">)</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"Application/macOS/Info.plist"</span><span class="p">)</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"Application/macOS/Base.lproj/*.storyboard"</span><span class="p">)</span>
        <span class="n">add_defines</span><span class="p">(</span><span class="s2">"TARGET_MACOS"</span><span class="p">)</span>
        <span class="n">add_frameworks</span><span class="p">(</span><span class="s2">"AppKit"</span><span class="p">)</span>
    <span class="k">elseif</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"iphoneos"</span><span class="p">)</span> <span class="k">then</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"Application/*.m"</span><span class="p">)</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"Application/iOS/Info.plist"</span><span class="p">)</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"Application/iOS/Base.lproj/*.storyboard"</span><span class="p">)</span>
        <span class="n">add_frameworks</span><span class="p">(</span><span class="s2">"UIKit"</span><span class="p">)</span>
        <span class="n">add_defines</span><span class="p">(</span><span class="s2">"TARGET_IOS"</span><span class="p">)</span>
</code></pre>
</div>

<p>比如，在 macOS 上，编译运行后，就会通过 metal 渲染出需要的效果。</p>

<p><img src="/static/img/xmake/xmake-metal.png" alt="" /></p>

<p>如果，我们的项目没有使用默认的 metal library，我们也可以通过上面提到的 <code class="highlighter-rouge">utils.bin2c</code> 规则，作为源文件的方式内嵌到代码库中，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"utils.bin2c"</span><span class="p">,</span> <span class="p">{</span><span class="n">extensions</span> <span class="o">=</span> <span class="s2">".metal"</span><span class="p">})</span>
<span class="n">add_files</span><span class="p">(</span><span class="s2">"Renderer/*.metal"</span><span class="p">)</span>
</code></pre>
</div>

<p>然后代码中，我们就能访问了：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">static</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">g_metal_data</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span>
    <span class="cp">#include "xxx.metal.h"
</span><span class="p">};</span>

<span class="n">id</span><span class="o">&lt;</span><span class="n">MTLLibrary</span><span class="o">&gt;</span> <span class="n">library</span> <span class="o">=</span> <span class="p">[</span><span class="n">_device</span> <span class="n">newLibraryWithSource</span><span class="o">:</span><span class="p">[[</span><span class="n">NSString</span> <span class="n">stringWithUTF8String</span><span class="o">:</span><span class="n">g_metal_data</span><span class="p">]]</span> <span class="n">options</span><span class="o">:</span><span class="n">nil</span> <span class="n">error</span><span class="o">:&amp;</span><span class="n">error</span><span class="p">];</span>
</code></pre>
</div>

<h3 id="改进-add_repositories">改进 add_repositories</h3>

<p>如果我们通过内置在项目中的本地仓库，我们之前是通过 <code class="highlighter-rouge">add_repositories("myrepo repodir")</code> 的方式来引入。</p>

<p>但是，它并不像 <code class="highlighter-rouge">add_files()</code> 那样是基于当前 xmake.lua 文件目录的相对目录，也没有路径的自动转换，因此容易遇到找不到 repo 的问题。</p>

<p>因此，我么你改进了下它，可以通过额外的 rootdir 参数指定对应的根目录位置，比如相对当前 xmake.lua 的脚本目录。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_repositories</span><span class="p">(</span><span class="s2">"myrepo repodir"</span><span class="p">,</span> <span class="p">{</span><span class="n">rootdir</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">scriptdir</span><span class="p">()})</span>
</code></pre>
</div>

<h3 id="oscp-支持符号链接">os.cp 支持符号链接</h3>

<p>之前的版本，<code class="highlighter-rouge">os.cp</code> 接口不能很好的处理符号链接的复制，他会自动展开链接，复制实际的文件内容，只会导致复制后，符号链接丢失。</p>

<p>如果想要复制后，原样保留符号链接，只需要设置下参数：<code class="highlighter-rouge"><span class="p">{</span><span class="err">symlink</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">true</span><span class="p">}</span></code></p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">os</span><span class="p">.</span><span class="n">cp</span><span class="p">(</span><span class="s2">"/xxx/symlink"</span><span class="p">,</span> <span class="s2">"/xxx/dstlink"</span><span class="p">,</span> <span class="p">{</span><span class="n">symlink</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<h3 id="更方便地编译自动生成的代码">更方便地编译自动生成的代码</h3>

<p>有时候，我们会有这样一个需求，在编译前，自动生成一些源文件参与后期的代码编译。但是由于 <code class="highlighter-rouge">add_files</code> 添加的文件在执行编译时候，就已经确定，无法在编译过程中动态添加它们（因为需要并行编译）。</p>

<p>因此，要实现这个需求，我们通常需要自定义一个 rule，然后里面主动调用编译器模块去处理生成代码的编译，对象文件的注入，依赖更新等一系列问题。</p>

<p>这对于 xmake 开发者本身没什么大问题，但是对于用户来说，这还是比较繁琐了，不好上手。</p>

<p>新版本中，我们改进了对 <code class="highlighter-rouge">add_files</code> 的支持，并添加了 <code class="highlighter-rouge"><span class="p">{</span><span class="err">always_added</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">true</span><span class="p">}</span></code> 配置来告诉 xmake 我们始终需要添加指定的源文件，即使它还不存在。</p>

<p>这样我们就可以依靠xmake的默认编译过程来编译自动生成的代码了，像这样：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"autogen_code"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"$(buildir)/autogen.cpp"</span><span class="p">,</span> <span class="p">{</span><span class="n">always_added</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
    <span class="n">before_build</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">)</span>
        <span class="n">io</span><span class="p">.</span><span class="n">writefile</span><span class="p">(</span><span class="s2">"$(buildir)/autogen.cpp"</span><span class="p">,</span> <span class="s">[[
#include &lt;iostream&gt;

using namespace std;

int main(int argc, char** argv)
{
    cout &lt;&lt; "hello world!" &lt;&lt; endl;
    return 0;
}
        ]]</span><span class="p">)</span>
    <span class="k">end</span><span class="p">)</span>
</code></pre>
</div>

<p>都不需要额外的 rule 定义，只需要保证编译顺序，在正确的阶段生成代码文件就可以了。</p>

<p>但是，我们也需要注意，由于当前自动生成的源文件可能还不存在，我们不能在 <code class="highlighter-rouge">add_files</code> 里面使用模式匹配，只能显式添加每个源文件路径。</p>

<h2 id="更新内容">更新内容</h2>

<h3 id="新特性">新特性</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1534">#1534</a>: 新增对 Vala 语言的支持</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1544">#1544</a>: 添加 utils.bin2c 规则去自动从二进制资源文件产生 .h 头文件并引入到 C/C++ 代码中</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1547">#1547</a>: option/snippets 支持运行检测模式，并且可以获取输出</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1567">#1567</a>: 新增 xmake-requires.lock 包依赖锁定支持</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1597">#1597</a>: 支持编译 metal 文件到 metallib，并改进 xcode.application 规则去生成内置的 default.metallib 到 app</li>
</ul>

<h3 id="改进">改进</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1540">#1540</a>: 更好更方便地编译自动生成的代码</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1578">#1578</a>: 改进 add_repositories 去更好地支持相对路径</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1582">#1582</a>: 改进安装和 os.cp 支持符号链接</li>
</ul>

<h3 id="bugs-修复">Bugs 修复</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1531">#1531</a>: 修复 targets 加载失败的错误信息提示错误</li>
</ul>


        </article>
        <hr>

        <!-- baidu ads -->
        

        <!-- reward -->
        <div style="text-align: center;">
            <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
              <span>赏</span>
            </button>
            <div id="QR" style="display: none;">
                <div id="wechat" style="display: inline-block">
                  <img id="wechat_qr" src="/static/img/weixin.png" alt="WeChat Pay"/>
                  <p>微信打赏</p>
                </div>
                <div id="alipay" style="display: inline-block">
                  <img id="alipay_qr" src="/static/img/alipay.png" alt="Alipay"/>
                  <p>支付宝打赏</p>
                </div>
            </div>
        </div>

        
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="english">English</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 released, Use lockfile to freeze package dependencies and Vala/Metal language support
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
        
            </ul>
        

        
        
            
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">相关文章</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/17/xmake-update-v2.6.2/">xmake v2.6.2 发布，新增 Linux 内核驱动模块构建支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 发布，使用 Lua5.4 运行时，Rust 和 C++ 混合编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        <p><strong>上一篇</strong> <a href="/cn/2021/07/26/xmake-update-v2.5.6/">xmake v2.5.6 发布，改进预编译二进制镜像包兼容性</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>下一篇</strong> <a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持</a></p>
        
    </div>
</div>


        <h2 id="comments">评论</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,       
  language: 'zh-CN',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    内容
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#english">English</a></li>
                    <li><a href="#similar_posts">相关文章</a></li>
                    <li><a href="#comments">评论</a></li>
                </ul>
            </div>


            <!-- baidu ads -->
            
            
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    链接
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- xmake courses -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193">
                </a>
            </div>

            <!-- qqgroup -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    技术交流群（QQ）
                </div>
                <img src="/static/img/qqgroup.png" alt="qqgroup" width="256" height="284">
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
